package com.soundnet.androidhelper.ui.activity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import com.amap.api.maps2d.MapView;
import com.soundnet.androidhelper.R;
import com.soundnet.androidhelper.callback.MapCallBack;
import com.soundnet.androidhelper.map.GaodeMap;
import com.soundnet.androidhelper.map.Map;

/**
 * 地图基类
 * lanstar 2016-03-28
 */

public class MapActivity extends BaseActivity {
    public Map mMap;
    public MapView mMapView;
    private Bundle mSavedInstanceState;
    public MapCallBack mMapCallBack;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mSavedInstanceState = savedInstanceState;
    }

    @Override
    public void setLayoutId(int layoutId) {
        super.setLayoutId(layoutId);

        initMapView();
    }

    public void initMapView() {
        mMapView = (MapView) getmContentView().findViewById(R.id.map);
        mMapView.onCreate(mSavedInstanceState);
        if (mMapView != null) {

            mMap = new GaodeMap(this, mMapView.getMap(), mMapCallBack);
            mMap.initMap();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (mMapView != null) {
            mMapView.onResume();
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (mMapView != null) {
            mMapView.onPause();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mMapView != null) {
            mMapView.onDestroy();
        }
    }
}
